// 花名册
function manageStu() {
    // 加载年级列表
    gradeList();

    // 选择年级加载班级
    gradeTeamList();

    // 加载辅导老师列表
    teacherList();

    // 添加新增按钮点击事件
    addBtnAction();

    // 添加搜索按钮点击事件
    queryBtnAction(pageClickAction);

    // 默认加载第一页数据
    pageClickAction();

    function pageClickAction() {
        var data = {
            token: sessionStorage.token,
            page: curPage
        };
        if ($('#grade_id').val()) data.name = $('#grade_id').val();
        if ($('#team_id').val()) team_id = $('#team_id').val();
        if ($('coach_teacher_id').val()) coach_teacher_id = $('#coach_teacher_id').val();

        $.ajax({
            url: http_url + 'Student/index',
            type: 'POST',
            data: data,
            success: function (response) {
                if (response.code == 0) {
                    // 移除原有的tr
                    $('tbody').find('tr').remove();
                    showStu(response,pageClickAction);
                }
            }
        });

    }
}

function showStu(response, pageClickAction) {
    // console.log(response);
    createPagiantion(response,pageClickAction);
    var list = response.data.data;
    list.reverse();
    list.forEach(function (list,index) {

        var tr = $('<tr/>').prop('tid',list.id);
        var td_id = $('<td/>').html((curPage - 1) * 10 + index +1);
        var td_name = $('<td/>').html(list.name);
        var td_number = $('<td/>').html(list.team );
        var td_tel = $('<td/>').html(list.tel);
        var td_state = $('<td/>').html(list.state);
        var td_situation = $('<td/>').html(list.situation);
        var td_deliver_address = $('<td/>').html(list.deliver_address);
        var td_time = $('<td>').html(timestampToTime(list.addtime));
        var td_action = $('<td/>').append($('<a/>').prop('href', '#').html('课程设置 ')).append($('<a/>').prop('href', '#').html('编辑'))
            .append($('<a/>').prop('href', '#').html('禁用')).append($('<a/>').prop('href', '#').html('重置密码'));
        tr.append(td_id).append(td_name).append(td_number).append(td_tel).append(td_state).append(td_situation).append(td_deliver_address).append(td_time).append(td_action);
        $('table').append(tr);
    });
}


